﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Miris.HumanMilkAnalyser.Repository.Interface
{
    /// <summary>
    /// A factory that manage every single repository.
    /// </summary>
    public interface IRepositoryFactory : IDisposable
    {
        /// <summary>
        /// Open a database connection with a transaction
        /// </summary>
        void OpenSessionWithTransaction();

        /// <summary>
        /// Open a database connection without a transaction
        /// </summary>
        void OpenSession();

        /// <summary>
        /// Rollback the transaction
        /// </summary>
        void Rollback();

        /// <summary>
        /// Commit the transaction
        /// </summary>
        void Commit();

        /// <summary>
        /// Flush current data
        /// </summary>
        void Flush();

        /// <summary>
        /// Commit the transaction based on the provided parameter and close the database connection
        /// </summary>
        void CloseSession();

        /// <summary>
        /// Create an instance of RepositoryBase against the specific DataModel type and provide standard CRUD operation only.
        /// </summary>
        /// <typeparam name="T">The provided DataModel type.</typeparam>
        /// <returns>An instance of RepositoryBase against the specific DataModel type and provide standard CRUD operation only.</returns>
        IRepository<T> CreateRepositoryBase<T>() where T : class;

        /// <summary>
        /// Create an instance of a class that implements IAnalysisResultDiagnosticMessageRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IAnalysisResultDiagnosticMessageRepository.</returns>
        IAnalysisResultDiagnosticMessageRepository CreateAnalysisResultDiagnosticMessageRepository();

        /// <summary>
        /// Create an instance of a class that implements IAnalysisItemRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IAnalysisItemRepository.</returns>
        IAnalysisItemRepository CreateAnalysisItemRepository();

        /// <summary>
        /// Create an instance of a class that implements IAnalysisResultRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IAnalysisResultRepository.</returns>
        IAnalysisResultRepository CreateAnalysisResultRepository();

        /// <summary>
        /// Create an instance of a class that implements IDiagnosticMessageReferenceRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IDiagnosticMessageReferenceRepository.</returns>
        IDiagnosticMessageReferenceRepository CreateDiagnosticMessageReferenceRepository();

        /// <summary>
        /// Create an instance of a class that implements IBreastfeedingSignificanceRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IBreastfeedingSignificanceRepository.</returns>
        IBreastfeedingSignificanceRepository CreateBreastfeedingSignificanceRepository();

        /// <summary>
        /// Create an instance of a class that implements IPatientRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IPatientRepository.</returns>
        IPatientRepository CreatePatientRepository();

        /// <summary>
        /// Create an instance of a class that implements IUnassignedSampleNumberRepository to do any operation against data source.
        /// </summary>
        /// <returns>An instance of class that implements IUnassignedSampleNumberRepository.</returns>
        IUnassignedSampleNumberRepository CreateUnassignedSampleNumberRepository();
    }
}
